<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
      <el-form-item label="仓库" prop="id">
        <el-select v-model="queryParams.id" placeholder="请选择仓库" clearable>
          <el-option
            v-for="dict in storeList"
            :key="dict.id"
            :label="dict.storeName"
            :value="dict.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="商品">
        <el-select v-model="queryParams.productId" placeholder="请选择商品" filterable clearable>
          <el-option
            v-for="dict in productList"
            :key="dict.productCode"
            :label="dict.productName"
            :value="dict.productCode"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="storeLogList">
      <el-table-column type="index" label="序号" width="55" align="center" />
      <el-table-column label="产品编码" align="center" prop="productId" :show-overflow-tooltip="true"/>
      <el-table-column label="产品名称" align="center" prop="productName" :show-overflow-tooltip="true"/>
      <el-table-column label="仓库名称" align="center" prop="storeName" />
      <el-table-column label="类型" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.wms_store" :value="scope.row.flag"/>
        </template>
      </el-table-column>
      <el-table-column label="操作数量" align="center" prop="operatorNum" />
      <el-table-column label="产生时间" align="center" prop="createTime" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listStoreXlk, listStoreLog } from "@/api/wms/store";
import { listProductXlk } from "@/api/wms/product";

export default {
  name: "ioStoreLog",
  dicts:['wms_store'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 仓库管理表格数据
      storeList: [],
      productList: [],
      storeLogList: [],
      queryParams: {
        id: null,
        productId: null
      }
    };
  },
  created() {
    this.getList();
    this.getCity();
  },
  methods: {
    /** 查询仓库管理列表 */
    getList() {
      this.loading = true;
      listStoreLog(this.queryParams).then(response => {
        this.storeLogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getCity(){
      listStoreXlk().then(response => {
        this.storeList = response.data;
      })
    },
    getProduct(){
      listProductXlk().then(response => {
        this.productList = response.data;
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
<style scoped>
.addressTitle{
  width: 90px;
  text-align: right;
  padding-right: 12px;
  line-height: 32px;
  font-size: 14px;
  color: #606266;
  font-weight: bold;
}
/deep/ .el-form-item--medium .el-form-item__content{
  line-height: 32px !important;
}
</style>
